package Controllers;

import java.awt.Component;
import java.awt.event.ActionEvent;

import javax.swing.JButton;
import javax.swing.JFrame;

import Boundry.ApproveDenyExtenstionGUI;
import Boundry.CloseRequestPanel;
import Boundry.EvluationScreenGUI;
import Boundry.InitTaskPanel;
import Boundry.NominateCommitteeAndInspectorPanel;
import Boundry.NominateExaminerGUI;
import Boundry.ResumeRequestPanel;
import Boundry.ReviewAndDecisionGUI;
import Boundry.SuspendRequestPanel;
import Boundry.TestingPanel;
import Boundry.WorkerPanel;
import Controllers.GenericToolsForController.BaseClass;

public class GUIControllerWorker extends BaseClass
{

	private WorkerPanel workpanel;
	
	/*
	 * Singleton
	 */
	private static  GUIControllerWorker Instance = null;
	private  GUIControllerWorker(){}
	public static GUIControllerWorker getInstance(){
		if (Instance == null ){
			Instance = new GUIControllerWorker();
		}
		return Instance;
	}
	
	
	void inizializtion()
	{
		workpanel = new WorkerPanel();
		GlobalData.mainScreen = workpanel;
		GlobalData.guiMangaer.switchScreen(workpanel);
		setListenerToInputPanel(workpanel);
		
		for (Component btn: workpanel.getMainPanel().getComponents())
		{	
			if (btn instanceof JButton)
				((JButton)btn).addActionListener(this);
		}
	
	}
		
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
		
		if (e.getSource() == workpanel.getBtnTaskInitiation()) // TODO ************** Guy Done **************
		{
			InspectorController.getInstance().initTask();
			System.out.println("InspectorController.getInstance().initTask()");			
		}
		else if (e.getSource() == workpanel.getBtnEvaluationRequest()) // TODO Ron
		{
			EvaluatorController.getInstance().evaluate();
			System.out.println("EvaluatorController.getInstance().evaluate()");
			
		}
		else if (e.getSource() == workpanel.getBtnNominateExaminer()) //TODO Guy
		{
			ChairmanController.getInstance().AssignExaminerToRequest();
			
			System.out.println("ChairmanController.getInstance().AssignExaminerToRequest()");
			
			
		}
		else if (e.getSource() == workpanel.getBtnReviewAndDecision()) // TODO Avi
		{
			ChairmanController.getInstance().reviewRequest();
			System.out.println("ChairmanController.getInstance().reviewRequest()");
			
		}
		else if (e.getSource() == workpanel.getBtnExecuteRequest()) // TODO Ron
		{
			ExecutionLeaderController.getInstance().execute();
			System.out.println("ExecutionLeaderController.getInstance().execute()");
			
		}
		else if (e.getSource() == workpanel.getBtnTesting()) // TODO Guy
		{
			ExaminerController.getInstance().examine();
			System.out.println("ExaminerController.getInstance().examine()");
			
		}
		else if (e.getSource() == workpanel.getBtnCloseRequest()) // TODO Shimon
		{
			System.out.println("InspectorController.getInstance().closeRequest()");
			InspectorController.getInstance().closeRequest();	
		}
		else if (e.getSource() == workpanel.getBtnSuspendRequest()) // TODO ************** Shimon Done **************
		{
			System.out.println("InspectorController.getInstance().suspendRequest()");
			InspectorController.getInstance().suspendRequest();
		}
		else if(e.getSource() == workpanel.getBtnSearchRequest()) // TODO**************  Guy Done **************
		{

			System.out.println("UserController.getInstance().searchRequest();	");
			UserController.getInstance().searchRequest();	
					
		}
		
		else if (e.getSource() == workpanel.getBtnViewRequests()) // TODO Ron
		{
			System.out.println("ICMManagerController.getInstance().showAllRequests();");
			InspectorController.getInstance().showAllRequests();
			
		}
		else if (e.getSource() == workpanel.getBtnSubmitRequest()) //TODO ************** Shimon - Done **************
		{
			System.out.println("UserController.getInstance().SubmitNewRequest();");
			UserController.getInstance().SubmitNewRequest();
				
		}
		else if(e.getSource() == workpanel.getBtnInspectorApproval()) // TODO Avi
		{
			System.out.println("InspectorController.getInstance().InspectorApproval()");
			InspectorController.getInstance().InspectorApproval();
		}
		
	}
	public static void main(String[] args){
		JFrame frame =  new JFrame();
		GuiManager guiMangaer = new GuiManager();
		GlobalData.guiMangaer = guiMangaer;
		
		//frame.setVisible(true);
		//frame.setBounds(0, 0, 700, 700);
		new GUIControllerWorker();
	}

}
